import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:life_service/color/hex.dart';
import 'package:life_service/extensions/ex_widget.dart';
import 'package:life_service/route/index.dart';
import 'package:life_service/ui/draw_under_line.dart';
import 'package:life_service/utils/styles.dart';
import 'package:life_service/utils/tools.dart';

class HomeMineController extends GetxController {}

class HomeMineView extends GetView<HomeMineController> {
  const HomeMineView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        backgroundColor: Colors.white,
        leading: Text(
          '我的',
          style: StylesUtils.customTextStyle(
            color: HexColor.color3333,
            fontSize: StylesUtils.fontSize18,
            fontWeight: FontWeight.w700,
          ),
        ).center(),
        systemOverlayStyle: SystemUiOverlayStyle.dark,
        actions: [
          IconButton(
            onPressed: () {},
            icon: Icon(
              CupertinoIcons.rocket_fill,
              size: 20,
              color: HexColor(HexColor.color3333),
            ),
          ),
          IconButton(
            onPressed: () {},
            icon: Icon(
              CupertinoIcons.leaf_arrow_circlepath,
              size: 20,
              color: HexColor(HexColor.color3333),
            ),
          ),
        ],
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Padding(
              padding: const EdgeInsets.only(left: 20),
              child: Row(
                children: [
                  const CircleAvatar(
                    backgroundImage: NetworkImage(
                        'https://img0.baidu.com/it/u=920698175,381618341&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800'),
                    radius: 30,
                  ),
                  Expanded(
                    child: Padding(
                      padding: const EdgeInsets.only(left: 15),
                      child: Column(
                        children: [
                          Container(
                            alignment: Alignment.centerLeft,
                            child: Text.rich(
                              TextSpan(
                                children: [
                                  TextSpan(
                                    text: '用户188****8766  ',
                                    style: StylesUtils.customTextStyle(
                                        fontSize: StylesUtils.fontSize16,
                                        color: HexColor.color1e1e),
                                  ),
                                  WidgetSpan(
                                    child: Icon(
                                      CupertinoIcons.eyedropper_halffull,
                                      size: 15,
                                      color: HexColor(HexColor.color3333),
                                    ),
                                    alignment: PlaceholderAlignment.middle,
                                  ),
                                ],
                              ),
                            ),
                          ),
                          Container(
                            margin: const EdgeInsets.only(top: 10),
                            alignment: Alignment.centerLeft,
                            child: TextButton(
                              onPressed: () {},
                              style: ButtonStyle(
                                fixedSize: const WidgetStatePropertyAll(
                                  Size(70, 22),
                                ),
                                minimumSize: const WidgetStatePropertyAll(
                                  Size(70, 22),
                                ),
                                backgroundColor: WidgetStatePropertyAll(
                                    HexColor.hex(HexColor.colorFfc7)),
                                alignment: Alignment.center,
                                shape: WidgetStatePropertyAll(
                                  RoundedRectangleBorder(
                                    borderRadius: BorderRadius.circular(11),
                                  ),
                                ),
                                padding: const WidgetStatePropertyAll(
                                    EdgeInsets.zero),
                              ),
                              child: Text(
                                '普通会员',
                                style: StylesUtils.customTextStyle(
                                  fontSize: StylesUtils.fontSize12,
                                ),
                              ),
                            ),
                          )
                        ],
                      ),
                    ),
                  ),
                ],
              ),
            ),
            Row(
              children: [
                Expanded(
                  child: Column(
                    children: [
                      Container(
                        height: 24,
                        alignment: Alignment.center,
                        child: Text(
                          '12',
                          style: StylesUtils.customTextStyle(
                            fontWeight: FontWeight.w700,
                            color: HexColor.color3333,
                          ),
                        ),
                      ),
                      Container(
                        height: 24,
                        alignment: Alignment.center,
                        child: Text(
                          '我的收藏',
                          style: StylesUtils.customTextStyle(
                            color: HexColor.colorCccc,
                            fontSize: StylesUtils.fontSize12,
                          ),
                        ),
                      )
                    ],
                  ),
                ),
                Expanded(
                  child: Column(
                    children: [
                      Container(
                        height: 24,
                        alignment: Alignment.center,
                        child: Text(
                          '30',
                          style: StylesUtils.customTextStyle(
                            fontWeight: FontWeight.w700,
                            color: HexColor.color3333,
                          ),
                        ),
                      ),
                      Container(
                        height: 24,
                        alignment: Alignment.center,
                        child: Text(
                          '浏览历史',
                          style: StylesUtils.customTextStyle(
                            color: HexColor.colorCccc,
                            fontSize: StylesUtils.fontSize12,
                          ),
                        ),
                      )
                    ],
                  ),
                ),
                Expanded(
                  child: Column(
                    children: [
                      Container(
                        height: 24,
                        alignment: Alignment.center,
                        child: Text(
                          '3',
                          style: StylesUtils.customTextStyle(
                            fontWeight: FontWeight.w700,
                            color: HexColor.color3333,
                          ),
                        ),
                      ),
                      Container(
                        height: 24,
                        alignment: Alignment.center,
                        child: Text(
                          '优惠券',
                          style: StylesUtils.customTextStyle(
                            color: HexColor.colorCccc,
                            fontSize: StylesUtils.fontSize12,
                          ),
                        ),
                      )
                    ],
                  ),
                ),
              ],
            ).paddingSymmetric(vertical: 20),
            Center(
              child: Container(
                width: 335,
                padding: const EdgeInsets.symmetric(vertical: 15),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(8),
                  boxShadow: [
                    BoxShadow(
                      offset: const Offset(0, 2),
                      blurRadius: 15,
                      spreadRadius: 0,
                      blurStyle: BlurStyle.outer,
                      color: HexColor.rgba(153, 153, 153, 0.349019607843137),
                    )
                  ],
                ),
                child: Column(
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text(
                          '我的订单',
                          style: StylesUtils.customTextStyle(
                            color: HexColor.color3333,
                            fontWeight: FontWeight.w700,
                          ),
                        ).paddingOnly(left: 15),
                        IconButton(
                          onPressed: () {
                            Get.toNamed(Routes.mineOrderList);
                          },
                          icon: Icon(
                            CupertinoIcons.chevron_right,
                            size: 14,
                            color: HexColor(HexColor.colorCccc),
                          ),
                        ),
                      ],
                    ),
                    Padding(
                      padding: const EdgeInsets.only(top: 20),
                      child: Row(
                        children: [
                          Expanded(
                            child: Column(
                              children: [
                                Center(
                                  child: Badge.count(
                                    count: 8,
                                    backgroundColor:
                                        HexColor(HexColor.colorFfc7),
                                    offset: const Offset(10, -5),
                                    child: ToolsUtils.image('u820.png',
                                        width: 20, height: 22),
                                  ),
                                ),
                                Container(
                                  margin: const EdgeInsets.only(top: 8),
                                  alignment: Alignment.center,
                                  child: Text(
                                    '全部订单',
                                    style: StylesUtils.customTextStyle(
                                      fontSize: StylesUtils.fontSize12,
                                      color: HexColor.color9999,
                                    ),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Expanded(
                            child: Column(
                              children: [
                                Center(
                                  child: Badge.count(
                                    count: 1,
                                    backgroundColor:
                                        HexColor(HexColor.colorFfc7),
                                    offset: const Offset(10, -5),
                                    child: ToolsUtils.image('u808.png',
                                        width: 20, height: 22),
                                  ),
                                ),
                                Container(
                                  margin: const EdgeInsets.only(top: 8),
                                  alignment: Alignment.center,
                                  child: Text(
                                    '待付款',
                                    style: StylesUtils.customTextStyle(
                                      fontSize: StylesUtils.fontSize12,
                                      color: HexColor.color9999,
                                    ),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Expanded(
                            child: Column(
                              children: [
                                Center(
                                  child: Badge.count(
                                    count: 2,
                                    backgroundColor:
                                        HexColor(HexColor.colorFfc7),
                                    offset: const Offset(10, -5),
                                    child: ToolsUtils.image('u812.png',
                                        width: 20, height: 22),
                                  ),
                                ),
                                Container(
                                  margin: const EdgeInsets.only(top: 8),
                                  alignment: Alignment.center,
                                  child: Text(
                                    '待入住',
                                    style: StylesUtils.customTextStyle(
                                      fontSize: StylesUtils.fontSize12,
                                      color: HexColor.color9999,
                                    ),
                                  ),
                                )
                              ],
                            ),
                          ),
                          Expanded(
                            child: Column(
                              children: [
                                Center(
                                  child: Badge.count(
                                    count: 4,
                                    backgroundColor:
                                        HexColor(HexColor.colorFfc7),
                                    offset: const Offset(10, -5),
                                    child: ToolsUtils.image('u816.png',
                                        width: 20, height: 22),
                                  ),
                                ),
                                Container(
                                  margin: const EdgeInsets.only(top: 8),
                                  alignment: Alignment.center,
                                  child: Text(
                                    '已消费',
                                    style: StylesUtils.customTextStyle(
                                      fontSize: StylesUtils.fontSize12,
                                      color: HexColor.color9999,
                                    ),
                                  ),
                                )
                              ],
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(top: 20, left: 20),
              child: Column(
                children: [
                  DrawUnderLine(
                    child: SizedBox(
                      height: 50,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text.rich(
                            TextSpan(
                              children: [
                                WidgetSpan(
                                  child: Icon(
                                    CupertinoIcons.ant_circle_fill,
                                    size: 20,
                                    color: HexColor(HexColor.color9999),
                                  ),
                                  alignment: PlaceholderAlignment.middle,
                                ),
                                TextSpan(
                                  text: '  会员中心',
                                  style: StylesUtils.customTextStyle(
                                    fontWeight: FontWeight.w700,
                                    color: HexColor.color3333,
                                  ),
                                ),
                              ],
                            ),
                          ),
                          IconButton(
                            onPressed: () {
                              Get.toNamed(Routes.mineMemberCenter);
                            },
                            icon: Icon(
                              CupertinoIcons.chevron_forward,
                              color: HexColor(HexColor.color3333),
                              size: 20,
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                  DrawUnderLine(
                    child: SizedBox(
                      height: 50,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text.rich(
                            TextSpan(
                              children: [
                                WidgetSpan(
                                  child: Icon(
                                    CupertinoIcons.ant_circle_fill,
                                    size: 20,
                                    color: HexColor(HexColor.color9999),
                                  ),
                                  alignment: PlaceholderAlignment.middle,
                                ),
                                TextSpan(
                                  text: '  我的钱包',
                                  style: StylesUtils.customTextStyle(
                                    fontWeight: FontWeight.w700,
                                    color: HexColor.color3333,
                                  ),
                                ),
                              ],
                            ),
                          ),
                          IconButton(
                            onPressed: () {
                              Get.toNamed(Routes.mineWalletBill);
                            },
                            icon: Icon(
                              CupertinoIcons.chevron_forward,
                              color: HexColor(HexColor.color3333),
                              size: 20,
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                  DrawUnderLine(
                    child: SizedBox(
                      height: 50,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text.rich(
                            TextSpan(
                              children: [
                                WidgetSpan(
                                  child: Icon(
                                    CupertinoIcons.ant_circle_fill,
                                    size: 20,
                                    color: HexColor(HexColor.color9999),
                                  ),
                                  alignment: PlaceholderAlignment.middle,
                                ),
                                TextSpan(
                                  text: '  领券中心',
                                  style: StylesUtils.customTextStyle(
                                    fontWeight: FontWeight.w700,
                                    color: HexColor.color3333,
                                  ),
                                ),
                              ],
                            ),
                          ),
                          IconButton(
                            onPressed: () {},
                            icon: Icon(
                              CupertinoIcons.chevron_forward,
                              color: HexColor(HexColor.color3333),
                              size: 20,
                            ),
                          ),
                        ],
                      ),
                    ).onTap(() {
                      Get.toNamed(Routes.mineCoupons);
                    }),
                  ),
                  DrawUnderLine(
                    child: SizedBox(
                      height: 50,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text.rich(
                            TextSpan(
                              children: [
                                WidgetSpan(
                                  child: Icon(
                                    CupertinoIcons.ant_circle_fill,
                                    size: 20,
                                    color: HexColor(HexColor.color9999),
                                  ),
                                  alignment: PlaceholderAlignment.middle,
                                ),
                                TextSpan(
                                  text: '  常用信息',
                                  style: StylesUtils.customTextStyle(
                                    fontWeight: FontWeight.w700,
                                    color: HexColor.color3333,
                                  ),
                                ),
                              ],
                            ),
                          ),
                          IconButton(
                            onPressed: () {
                              Get.toNamed(Routes.mineUsedInfo);
                            },
                            icon: Icon(
                              CupertinoIcons.chevron_forward,
                              color: HexColor(HexColor.color3333),
                              size: 20,
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                  DrawUnderLine(
                    child: SizedBox(
                      height: 50,
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text.rich(
                            TextSpan(
                              children: [
                                WidgetSpan(
                                  child: Icon(
                                    CupertinoIcons.bolt_fill,
                                    size: 20,
                                    color: HexColor(HexColor.color9999),
                                  ),
                                  alignment: PlaceholderAlignment.middle,
                                ),
                                TextSpan(
                                  text: '  我的评价',
                                  style: StylesUtils.customTextStyle(
                                    fontWeight: FontWeight.w700,
                                    color: HexColor.color3333,
                                  ),
                                ),
                              ],
                            ),
                          ),
                          IconButton(
                            onPressed: () {},
                            icon: Icon(
                              CupertinoIcons.chevron_forward,
                              color: HexColor(HexColor.color3333),
                              size: 20,
                            ),
                          ),
                        ],
                      ),
                    ).onTap(() {
                      Get.toNamed(Routes.mineEvaluate);
                    }),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
